var   fs   = require('fs'),
      http = require('http'),
      path = require('path'),
      file = process.argv[2];

var data = fs.readFileSync(file).toString('base64');
let ext  = path.extname(file);
let urll = 'data:image/' + ext.slice(1, ext.length) + ';base64,' + data;

var html = `
  <!DOCTYPE html>
  <html>
    <head><title>图片</title></head>
    <body>
      <img src="${urll}">
    </body>
  </html>`;

http.createServer((req, res) => {
  console.log(req.headers);
  console.log(req.url + '\n');
  res.end(html);
}).listen(8081);
